package com.forlove.app.qselect.friend.widget.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.widget.TextView;

import com.forlove.app.R;
import com.forlove.app.common.widget.dialog.AnimationType;

/**
 * 信息展示的通用弹窗
 * Created by yjl on 2017/10/12.
 */

public class ShowInfoDialog extends Dialog {
    private Window mWindow;
    private Context mContext;

    /**
     * 进入动画是windowAnimation windowAnimation定义在style中.
     */
    protected int[] mAnimations = {R.style.QYQ_Dialog_Animation_Fly,
            R.style.QYQ_Dialog_Animation_Fade,
            R.style.QYQ_Toast_Animation_Fly,
            R.style.QYQ_Toast_Animation_Fade,
            R.style.QYQ_Dialog_Animation_FlyInFadeOut,
            R.style.QYQ_Dialog_Animation_FlyInFlyOut,
            R.style.QYQ_Toast_Animation_FlyInFlyOut,
            R.style.QYQ_Toast_Animation_FlyTopInFlyTopOut};

    private TextView text_messeage;
    private TextView dialog_agree;
    private TextView dialog_cancel;
    private TextView text_title;

    public ShowInfoDialog(Context context) {
        super(context, R.style.showDialog);
        setContentView(R.layout.dialog_show_tip_info);
        mWindow = getWindow();
        mContext = context;
        mWindow.setWindowAnimations(mAnimations[AnimationType.TOAST_FADE.getValue()]);
        mWindow.setGravity(Gravity.CENTER);
        mWindow.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.bg_gray_corner));
        dialog_agree = (TextView) findViewById(R.id.dialog_agree);
        text_messeage = (TextView) findViewById(R.id.text_messeage);
        dialog_cancel = findViewById(R.id.dialog_cancel);
        text_title = findViewById(R.id.text_title);

    }

    public void setTitle(String textTitle) {
        text_title.setText(textTitle);
        text_title.setVisibility(View.VISIBLE);
    }

    public void setTitle(int resId) {
        text_title.setText(resId);
        text_title.setVisibility(View.VISIBLE);
    }

    public void setTextMesseage(String textMesseage) {
        text_messeage.setText(textMesseage);
    }

    public void setTextMesseage(CharSequence textMesseage) {
        text_messeage.setText(textMesseage);
    }

    public void setTextMesseage(int msgId) {
        text_messeage.setText(msgId);
    }

    public void setAgreeListener(View.OnClickListener agreeListener) {
        this.dialog_agree.setOnClickListener(agreeListener);
    }

    public void setAgree(String msg) {
        setAgree(msg, null);
    }

    public void setAgree(int msgId) {
        setAgree(msgId, null);
    }

    public void setAgree(int msgId, View.OnClickListener onClickListener) {
        dialog_agree.setText(msgId);
        dialog_agree.setOnClickListener(onClickListener);
    }

    public void setAgree(String msg, View.OnClickListener onClickListener) {
        dialog_agree.setText(msg);
        dialog_agree.setOnClickListener(onClickListener);
    }

    public void setCancel(String msg, View.OnClickListener onClickListener) {
        dialog_cancel.setText(msg);
        dialog_cancel.setOnClickListener(onClickListener);
    }

    public void setCancel(int msgId, View.OnClickListener onClickListener) {
        dialog_cancel.setText(msgId);
        dialog_cancel.setOnClickListener(onClickListener);
    }

    public void setCancel(String msg) {
        setCancel(msg, null);
    }

    public void setCancel(int msgId) {
        setCancel(msgId, null);
    }

    public void hideLeftButton() {
        dialog_cancel.setVisibility(View.GONE);
    }

    public void hidrRightButton() {
        dialog_agree.setVisibility(View.GONE);
    }
}
